<template>
    <el-carousel :interval="4000" type="card" height="400px" >
        <el-carousel-item v-for="item in carouselItems" :key="item.id">
            <img :src=item.image class="swipper"
                @click="jump('https://element-plus.org/zh-CN/component/menu.html', item.id)" />
            <h3 text="2xl" justify="center">{{ item.id }}</h3>
        </el-carousel-item>
    </el-carousel>
</template>

<script setup>

import { reactive } from 'vue';

// 后续换为接口获取json对象
const carouselItems = reactive([
    { id: 1, image: '/img/1.jpg' },
    { id: 2, image: '/img/2.jpg' },
    { id: 3, image: '/img/3.jpg' },
    { id: 4, image: '/img/4.jpg' },
]);

function jump(path, id) {
    // 跳转到其他网站
    window.open(path);
    console.log(id)
}

</script>

<style scoped>
.el-carousel__item {
    margin: 0;
    padding: 0;
}

.el-carousel__item h3 {
    color: #475669;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
    text-align: center;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
    background-color: #d3dce6;
}

.swipper {
    max-width: 100%;
        height: auto;
}
</style>